__author__ = 'nvsmirnov'
# -*- coding: utf-8 -*-

from Framework.PageClasses._CpBase import _CpBase
from Framework.DataClasses.CommonData import CommonData

class CpSignContract(_CpBase):
    def openMainForm(self):
        self.presence_of_element_located('content-area')

    def openAuction(self, id):
        #Открыть аукцион
        url = CommonData.url + 'common/contract/view2/auction/' + id
        self.driver.get(url)
        current_url = self.driver.current_url
        print "Открылся url: ", current_url
        assert current_url == url

    def fillForm(self):
        #Нажать кнопку
        self.presence_of_element_located_byXpath(".//*[@type='button' and contains(.,'Подписать последний актуальный проект контракта')]")
        self.driver.find_element_by_xpath(".//*[@type='button' and contains(.,'Подписать последний актуальный проект контракта')]").click()

        #Подписать
        self.presence_of_element_located_byXpath(".//*[@type='button' and contains(.,'Подписать')]")
        #self.driver.find_element_by_xpath(".//*[@type='button' and contains(.,'Подписать')]").click()
        self.driver.find_element_by_xpath(".//*[text()='Подписать']").click()
    """
    def submitForm(self):
        #JS Alert
        self.wait_for_alert()
        self.driver.switch_to.alert.accept()
        #Certificate window
        self.submit_certificate_window()
        #JS Alert
        self.wait_for_alert()
        self.driver.switch_to.alert.accept()
        #JS Alert еще один!
        self.wait_for_alert()
        self.driver.switch_to.alert.accept()

        self.presence_of_element_located_byXpath(".//*[text()='Контракт подписан']")
        self.driver.find_element_by_xpath(".//*[@type='button' and contains(.,'OK')]").click()
    """